//index.js
//获取应用实例
var app = getApp();
var util = require('../../utils/util.js');
Page({
    data: {
        hiddenLoading: false
    },

    onLoad: function () {
        //考试报名列表
        util.https("Home", "getExamList", {

            }
            ,
            this.getHeadExamType
        )
        //考试头条
        util.https("Home", "getHeadLines", {

            },
            this.getHeadLines
        )

        //首页活动报名列表
        util.https("Home", "getActList", {

            },
            this.getHeadActiveList
        )
    },
    //考试报名列表
    getHeadExamType: function (data) {
        var headExamType = data.list;
        for (var index in headExamType) {
            //考试时间差
            headExamType[index].differdays = Math.floor((new Date(headExamType[index].exam_start_date).getTime() - new Date().getTime()) / (24 * 3600 * 1000));
            // headExamType[index].differdays = headExamType[index].differdays
        }
        this.setData({
            headExamType: headExamType
        });


    },
    //考试头条
    getHeadLines: function (data) {
        console.log('============')
        console.log(data.list);
        console.log('============')

        this.setData({
            headLine: data.list
        });

    },
    //首页活动报名列表
    getHeadActiveList: function (data) {
        console.log('============')
        console.log(data.list);
        console.log('============')

        var headActiveList = data.list;
        for (var index in headActiveList) {
            //考试时间差
            headActiveList[index].differdays = Math.floor((new Date(headActiveList[index].sign_start_time).getTime() - new Date().getTime()) / (24 * 3600 * 1000));
            // headActiveList[index].differdays = headActiveList[index].differdays
        }
        this.setData({
            headActiveList: headActiveList
        });

    },
})
